﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FightTheDragon.Managers;

using FightTheDragon.Interface;
using FightTheDragon.GameObjects;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace FightTheDragon.States
{
    class PauseState: BaseState
    {
        private InterfaceManager m_Interface;
        private InputManager m_Input;
        private StateManager m_States;
        private Text m_Pause;
        private Cursor m_Cursor;
        public enum States { RESUME = 2, OPTIONS, QUIT };

        public PauseState()
        {
            m_Interface = null;
            m_Input = null;
            m_States = null;
            m_Pause = new Text();
            m_Cursor = new Cursor();
            
        }
        void BaseState.Enter()
        {
            m_Interface = InterfaceManager.Instance;
            m_Input = InputManager.Instance;
            m_States = StateManager.Instance;
            m_Pause = new Text(1280 / 2, 760 / 2, 0, "SpriteFont1", "PAUSED\nResume\nOptions\nQuit", 1, Color.Red, 0, new RotateEffect(true));
            m_Cursor = new Cursor(0, "MMeteor", .5f, Color.White, 1, m_Pause, 2, 4);
            m_Interface.Add(m_Pause);
            m_Interface.Add(m_Cursor);

        }
        void BaseState.Exit()
        {
            m_Interface.Remove(m_Pause);
            m_Interface.Remove(m_Cursor);
        }
        bool BaseState.HandleInput()
        {
            if (m_Input.ButtonPressedOnce(Buttons.LeftThumbstickDown) || m_Input.ButtonPressedOnce(Buttons.DPadDown))
                m_Cursor.CursorMovement++;
            if (m_Input.ButtonPressedOnce(Buttons.LeftThumbstickUp) || m_Input.ButtonPressedOnce(Buttons.DPadUp))
                m_Cursor.CursorMovement--;

            if (m_Input.ButtonPressedOnce(Buttons.A))
            {
                switch (m_Cursor.CursorMovement)
                {
                        //May have to change later for Game to not update but be presemt in background
                    case(int)States.RESUME:
                        m_States.PopState();
                        break;
                    case(int)States.OPTIONS:
                        m_States.ChangeState(new OptionState());
                        break;
                    case(int)States.QUIT:
                        m_States.ChangeState(new ExitState());
                        break;
                }
            }

            return false;
        }
        void BaseState.Render()
        {
            m_Interface.Render();

        }
        void BaseState.Update(float gTime)
        {
            m_Input.Update();
            m_Interface.Update(gTime);
        }
    }
}
